package Q2;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m = scanner.nextInt();

        Set<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }

        for (int i = 0; i < m; i++) {
            set.add(scanner.nextInt());
        }

        for (int i : set) {
            System.out.print(i + " ");
        }
    }
}
